#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
struct car{
	int d,v,a;
}f[N];
struct node{
	int pl,pr;
}a[N];
int T;
int n,m,L,V;
int p[N];
bool cmp(node x,node y){
	if(x.pl==y.pl) return x.pr<y.pr;
	return x.pl<y.pl;
}
int main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	scanf("%d",&T);
	while(T--){
		int ans1=0,b=0,ans2=1;
		scanf("%d%d%d%d",&n,&m,&L,&V);
		for(int i=1;i<=n;i++) scanf("%d%d%d",&f[i].d,&f[i].v,&f[i].a);
		for(int i=1;i<=m;i++) scanf("%d",&p[i]);
		for(int i=1;i<=n;i++){
			if(f[i].d>p[m]) continue;
			int k=0;
			int l=1,r=m,mid;
			while(l<r){
				mid=(l+r)>>1;
				if(f[i].d>p[mid]) l=mid+1;
				else r=mid;
			}
			k=l;
			if(f[i].a>=0){
				int t=V*V-f[i].v*f[i].v;
				if(2*f[i].a*(p[m]-f[i].d)>t) {
					ans1++;
					l=k,r=m;
					while(l<r){
						mid=(l+r)>>1;
						if(2*f[i].a*(p[mid]-f[i].d)>t) r=mid;
						else l=mid+1;
					}
					b++;
					a[b].pl=l,a[b].pr=m;
				}
			}
			else {
				int t=V*V-f[i].v*f[i].v;
				if(2*f[i].a*(p[k]-f[i].d)>t) {
					ans1++;
					l=k,r=m;
					while(l<r){
						mid=(l+r)>>1;
						if(2*f[i].a*(p[mid]-f[i].d)>t) l=mid;
						else r=mid-1;
					}
					b++;
					a[b].pl=k,a[b].pr=l;
				}
			}
		}
		if(ans1==0) ans2=m;
		else{
			sort(a+1,a+b+1,cmp);
			int st=1,ed=1,q=a[1].pl,q1;
			for(int i=2;i<=b;i++){
				if(a[i].pl==q){
					ed++;
					continue;
				}
				q1=a[i].pl;
				bool flag=0;
				for(int j=st;j<=ed;j++){
					if(q1>a[j].pr){
						ans2++;
						st=ed=i;
						flag=1;
						break;
					}
				}
				if(!flag) q=q1,ed++;
			}
			ans2=m-ans2;
		}
		printf("%d %d\n",ans1,ans2);
	}
	return 0;
}

